// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/

// type typeUpImgRes = {
//     code: number,
//     url: string, 
//     alt: string, 
//     href: string
// }



#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

// // https://v2.tauri.org.cn/develop/calling-rust/#error-handling
// #[tauri::command]
// fn tauri_fn_upload_image(file: String) -> Result<String, String> {
//     if file {
//         // resolve
//         Ok("logged_in".to_string())
//     } else {
//         // reject
//         Err("invalid credentials".to_string())
//     }
// }

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_upload::init())
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_store::Builder::new().build())
        .plugin(tauri_plugin_http::init())
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
